package project2.ui.game.auto;

import project2.config.Config;
import project2.config.ImageConstants;
import project2.resources.Images;
import project2.ui.game.GamePlayingPanel;

import java.awt.*;

public class BombShow {
    private final GamePlayingPanel panel;

    public BombShow(GamePlayingPanel panel) {
        this.panel = panel;
    }

    public void run(Graphics g) {
        if (panel.myPlane.getHoldBombCount() > 0) {
            Graphics2D g2d = (Graphics2D) g;
            int posX = Config.CAUGHT_BOMB_IMG_POS_X;
            int posY = Config.CAUGHT_BOMB_IMG_POS_Y;
            g2d.drawImage(Images.CAUGHT_BOMB_IMG, posX, posY, ImageConstants.CAUGHT_BOMB_WIDTH, ImageConstants.CAUGHT_BOMB_HEIGHT, panel);

            posX += ImageConstants.CAUGHT_BOMB_WIDTH;
            posY += (ImageConstants.CAUGHT_BOMB_HEIGHT - ImageConstants.X_MARK_HEIGHT) / 2;

            g2d.drawImage(Images.X_MARK_IMG, posX, posY, ImageConstants.X_MARK_WIDTH, ImageConstants.X_MARK_HEIGHT, panel);
            posX += ImageConstants.X_MARK_WIDTH;
            switch (panel.myPlane.getHoldBombCount()) {
                case Config.ONE_BOMB:
                    g2d.drawImage(Images.NUMBER_1_IMG, posX, posY, ImageConstants.NUMBER_1_WIDTH, ImageConstants.NUMBER_1_HEIGHT, panel);
                    break;
                case Config.TWO_BOMB:
                    g2d.drawImage(Images.NUMBER_2_IMG, posX, posY, ImageConstants.NUMBER_2_WIDTH, ImageConstants.NUMBER_2_HEIGHT, panel);
                    break;
                case Config.THREE_BOMB:
                    g2d.drawImage(Images.NUMBER_3_IMG, posX, posY, ImageConstants.NUMBER_3_WIDTH, ImageConstants.NUMBER_3_HEIGHT, panel);
                    break;
            }
        }
    }
}
